﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Serialization;

namespace Test.Silverlight.DataGrid
{
    public class OrderDataSourceCreator
    {
        public static List<Order> CreateDataSource() { return CreateDataSource(1000); }
        public static List<Order> CreateDataSource(int rowCount)
        {
            List<Order> list = new List<Order>();
            for (int i = 0; i < rowCount; i++)
            {
                list.Add(CreateItem(i + 1));
            }
            return list;
        }

        static Order CreateItem(int id)
        {
            Order order = new Order();
            order.ID = id;
            order.Name = "Name " + id.ToString();
            order.OrderDate = DateTime.Today.AddDays(-id % 20);
            order.Price = 100 + id % 10;
            order.Quantity = 10 + id % 15;

            order.Preview = "c:/0.png";
            return order;
        }
    }

    public class Order
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime OrderDate { get; set; }
        public decimal Price { get; set; }
        public int Quantity { get; set; }
        public decimal Total { get { return Price * Quantity; } }
        public string Preview { get; set; }
    }

    public class MovieDataSourceCreator
    {
        public static List<Movie> CreateDataSource() { return CreateDataSource(10); }
        public static List<Movie> CreateDataSource(int rowCount)
        {
            List<Movie> list = new List<Movie>();
            for (int i = 0; i < 1000; i++)
            {
                list.Add(CreateItem(i + 1));
            }
            return list;
        }

        static Movie CreateItem(int id)
        {
            Movie order = new Movie();
            order.ID = id;
            order.Name = "Name " + id.ToString();
            order.OrderDate = DateTime.Today.AddDays(-id % 20);
            order.Price = 100 + id % 10;
            order.Quantity = 10 + id % 15;
            order.Preview = "movies/0.wmv";
            return order;
        }
    }

    public class Movie
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime OrderDate { get; set; }
        public decimal Price { get; set; }
        public int Quantity { get; set; }
        public decimal Total { get { return Price * Quantity; } }
        public string Preview { get; set; }
    }
    public class Cars
    {
        public int ID { get; set; }
        public string Trademark { get; set; }
        public string Model { get; set; }
        public int HP { get; set; }
        public double Liter { get; set; }
        public int Cyl { get; set; }
        public int TransmissSpeedCount { get; set; }
        public string TransmissAutomatic { get; set; }
        public int MPGCity { get; set; }
        public int MPGHighway { get; set; }
        public string Category { get; set; }
        public string Description { get; set; }
        public string Hyperlink { get; set; }
        public byte[] Picture { get; set; }
        public decimal Price { get; set; }
        public DateTime DeliveryDate { get; set; }
        public bool IsInStock { get; set; }
    }
    [XmlRoot("NewDataSet")]
    public class CarsData : List<Cars>
    {
        public static object DataSource
        {
            get
            {
                XmlSerializer s = new XmlSerializer(typeof(CarsData));
                return s.Deserialize(typeof(CarsData).Assembly.GetManifestResourceStream(typeof(CarsData).Namespace + ".Cars.xml"));
            }
        }
    }
    //public struct Date : DateTime {
    //    public override string ToString() {
    //        return base.ToString();
    //    }
    //}
    public class Employees
    {
        public int EmployeeID { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string Title { get; set; }
        public string TitleOfCourtesy { get; set; }
        public DateTime BirthDate { get; set; }
        public DateTime HireDate { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string Region { get; set; }
        public string PostalCode { get; set; }
        public string Country { get; set; }
        public string HomePhone { get; set; }
        public string Extension { get; set; }
        public double Salary { get; set; }
        public bool OnVacation { get; set; }
        public byte[] Photo { get; set; }
        public string Notes { get; set; }
        public int ReportsTo { get; set; }
    }
    [XmlRoot("NewDataSet")]
    public class EmployeesData : List<Employees>
    {
        public static object DataSource
        {
            get
            {
                XmlSerializer s = new XmlSerializer(typeof(EmployeesData));
                return s.Deserialize(typeof(EmployeesData).Assembly.GetManifestResourceStream(typeof(EmployeesData).Namespace + ".Employees.xml"));
            }
        }
    }
    public class Invoices
    {
        public string country { get; set; }
        public string city { get; set; }
        public DateTime orderdate { get; set; }
        public decimal unitprice { get; set; }
        public int quantity { get; set; }
    }

    [XmlRoot("NewDataSet")]
    public class InvoicesData : List<Invoices>
    {
        public static object DataSource
        {
            get
            {
                XmlSerializer s = new XmlSerializer(typeof(InvoicesData));
                return s.Deserialize(typeof(InvoicesData).Assembly.GetManifestResourceStream(typeof(InvoicesData).Namespace + ".Invoices.xml"));
            }
        }
    }
}
